<?php
/**
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1
 * @license    GNU/GPL
*/
 
// no direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.view');
jimport( 'joomla.filesystem.path' );

jimport( 'joomla.database.database' );
 
/**
 * HTML View class for the HelloWorld Component
 *
 * @package    HelloWorld
 */
 
class wotclanViewsettanks extends JView
{
    function display($tpl = null)
    {
    	if (JFactory::getUser()->authorise('core.add', 'com_wotclan')) 
      {
      	include JPATH_COMPONENT.DS.'functions.php';
    	  $greeting = "Les tanks de la DB!";
        $this->assignRef( 'greeting', $greeting );
        parent::display($tpl);
        	$db =& JFactory::getDbo();
  $greeting = "Les tanks de la DB!";
  
  $query = $db->getQuery(true);
  $query="SELECT * FROM `#__wotclan_tanks`";// WHERE `lvl`='0' OR `tanktype`='0'"; // WHERE `lvl`='0' OR `tanktype`='0'";
  $db->setQuery($query);
  $db->query();
  $num_rows = $db->getNumRows();
  $rows = $db->loadObjectList();
  echo "<div align='center'><table><tr><td>name</td><td>Nom Commun</td><td>type</td><td>lvl</td><td></td></tr>";
  foreach ( $rows as $row ) {
  	echo "<form method='post' action='?view=save&id=".$row->uniqid."'><tr><td>";
  	showimgtank($row->name,$row->common_name,$row->tanktype,$row->uniqid);
  	echo "</td><td><input name='common_name' type='text' value='".$row->common_name."'></input>";
  	echo "</td>";
  	
  		
  	echo "<td><select name='tanktype'>
		<option value='0'";
		if($row->tanktype == 0){echo " selected='selected' ";}
		echo ">Inconnu</option><option value='1' ";
		if($row->tanktype == 1){echo " selected='selected' ";}
		echo ">Tank Lourd</option><option value='2' ";
		if($row->tanktype == 2){echo " selected='selected' ";}
		echo ">Tank Medium</option><option value='3' ";
		if($row->tanktype == 3){echo " selected='selected' ";}
		echo "> Tank Leger</option><option value='4' ";
		if($row->tanktype == 4){echo " selected='selected' ";}
		echo "> Tank Destroyer</option><option value='5' ";
		if($row->tanktype == 5){echo " selected='selected' ";}
		echo ">Artillerie</option></select></td>";
  	
  	
  	echo "<td><select name='lvl'><option value='0' ";
  	if($row->lvl == 0){echo " selected='selected' ";}
  	echo ">Inconnu</option><option value='1' ";
  	if($row->lvl == 1){echo " selected='selected' ";}
  	echo ">1</option><option value='2' ";
  	if($row->lvl == 2){echo " selected='selected' ";}
  	echo ">2</option><option value='3' ";
  	if($row->lvl == 3){echo " selected='selected' ";}
  	echo ">3</option><option value='4' ";
  	if($row->lvl == 4){echo " selected='selected' ";}
  	echo ">4</option><option value='5' ";
  	if($row->lvl == 5){echo " selected='selected' ";}
  	echo ">5</option><option value='6' ";
  	if($row->lvl == 6){echo " selected='selected' ";}
  	echo ">6</option><option value='7' ";
  	if($row->lvl == 7){echo " selected='selected' ";}
  	echo ">7</option><option value='8' ";
  	if($row->lvl == 8){echo " selected='selected' ";}
  	echo ">8</option><option value='9' ";
  	if($row->lvl == 9){echo " selected='selected' ";}
  	echo ">9</option><option value='10' ";
  	if($row->lvl == 10){echo " selected='selected' ";}
  	echo ">10</option></select></td>";
  		
  	
  	echo "<td><input type='submit' value='Sauvegarder'> </td> </tr></form>";
  }
  echo"</table>

</div>";

      } else {
    		$greeting = "Vous n'avez pas acces a cette section!";
        $this->assignRef( 'greeting', $greeting );
 
        parent::display($tpl);
    		
      }
    
    }
}

